
package com.joysuch.wwyt.bp.enums;

/**
 * 生产装置状态
 *
 */
public enum DeviceFacilityRepairStates {

    OK(1, "完好"), REPAIRING(2, "维修中");

    private int id;
    private String name;

    private DeviceFacilityRepairStates(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public boolean is(Integer state) {
        return state != null && state.intValue() == id;
    }

    public static DeviceFacilityRepairStates findByName(String name) {
        DeviceFacilityRepairStates[] values = DeviceFacilityRepairStates.values();
        for (DeviceFacilityRepairStates v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static DeviceFacilityRepairStates findById(Integer level) {
        DeviceFacilityRepairStates[] values = DeviceFacilityRepairStates.values();
        for (DeviceFacilityRepairStates v : values) {
            if (v.getId() == level) {
                return v;
            }
        }
        return null;
    }

    public static String findNameById(Integer id) {
        if (id == null) {
            return null;
        }
        DeviceFacilityRepairStates[] values = DeviceFacilityRepairStates.values();
        for (DeviceFacilityRepairStates v : values) {
            if (v.getId() == id) {
                return v.getName();
            }
        }
        return null;
    }
}
